home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / windows / ocx / ipack.exe / FTPMAIN.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-04-20  |  9.9 KB  |  313 lines

  1. VERSION 4.00
  2. Begin VB.MDIForm MainForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Mabry FTP Sample Program"
  5.    ClientHeight    =   8460
  6.    ClientLeft      =   3570
  7.    ClientTop       =   1425
  8.    ClientWidth     =   9105
  9.    Height          =   8865
  10.    Left            =   3510
  11.    LinkTopic       =   "MDIForm1"
  12.    Top             =   1080
  13.    Width           =   9225
  14.    Begin VB.PictureBox Picture3 
  15.       Align           =   2  'Align Bottom
  16.       Height          =   375
  17.       Left            =   0
  18.       ScaleHeight     =   315
  19.       ScaleWidth      =   9045
  20.       TabIndex        =   9
  21.       Top             =   8085
  22.       Width           =   9105
  23.       Begin VB.Label Label7 
  24.          Height          =   180
  25.          Left            =   7695
  26.          TabIndex        =   17
  27.          Top             =   60
  28.          Width           =   1110
  29.       End
  30.       Begin VB.Label Label6 
  31.          Alignment       =   1  'Right Justify
  32.          Caption         =   "Progress:"
  33.          Height          =   165
  34.          Left            =   6735
  35.          TabIndex        =   16
  36.          Top             =   60
  37.          Width           =   855
  38.       End
  39.       Begin VB.Label Label5 
  40.          Alignment       =   1  'Right Justify
  41.          Caption         =   "State:"
  42.          Height          =   255
  43.          Left            =   1380
  44.          TabIndex        =   15
  45.          Top             =   60
  46.          Width           =   615
  47.       End
  48.       Begin VB.Label Label4 
  49.          Alignment       =   1  'Right Justify
  50.          Caption         =   "Last Error:"
  51.          Height          =   255
  52.          Left            =   2580
  53.          TabIndex        =   14
  54.          Top             =   60
  55.          Width           =   855
  56.       End
  57.       Begin VB.Label Label3 
  58.          Alignment       =   1  'Right Justify
  59.          Caption         =   "Last Action:"
  60.          Height          =   255
  61.          Left            =   60
  62.          TabIndex        =   13
  63.          Top             =   60
  64.          Width           =   855
  65.       End
  66.       Begin VB.Label lblState 
  67.          Caption         =   "Label2"
  68.          Height          =   255
  69.          Left            =   2100
  70.          TabIndex        =   12
  71.          Top             =   60
  72.          Width           =   615
  73.       End
  74.       Begin VB.Label lblLastError 
  75.          Caption         =   "Label2"
  76.          Height          =   255
  77.          Left            =   3540
  78.          TabIndex        =   11
  79.          Top             =   60
  80.          Width           =   975
  81.       End
  82.       Begin VB.Label lblLastAction 
  83.          Caption         =   "Label2"
  84.          Height          =   255
  85.          Left            =   1020
  86.          TabIndex        =   10
  87.          Top             =   60
  88.          Width           =   375
  89.       End
  90.    End
  91.    Begin VB.PictureBox Picture2 
  92.       Align           =   1  'Align Top
  93.       Height          =   435
  94.       Left            =   0
  95.       ScaleHeight     =   375
  96.       ScaleWidth      =   9045
  97.       TabIndex        =   3
  98.       Top             =   3975
  99.       Width           =   9105
  100.       Begin VB.Timer Timer1 
  101.          Interval        =   1
  102.          Left            =   6360
  103.          Top             =   0
  104.       End
  105.       Begin VB.CommandButton cmdFileTransfers 
  106.          Caption         =   "File Transfers"
  107.          Height          =   375
  108.          Left            =   2670
  109.          TabIndex        =   6
  110.          Top             =   0
  111.          Width           =   1335
  112.       End
  113.       Begin VB.CommandButton cmdDirectory 
  114.          Caption         =   "Directory"
  115.          Height          =   375
  116.          Left            =   1335
  117.          TabIndex        =   5
  118.          Top             =   0
  119.          Width           =   1335
  120.       End
  121.       Begin VB.CommandButton cmdConnection 
  122.          Caption         =   "Connection"
  123.          Height          =   375
  124.          Left            =   0
  125.          TabIndex        =   4
  126.          Top             =   0
  127.          Width           =   1335
  128.       End
  129.       Begin FTPLib.mFTP FTP1 
  130.          Left            =   5760
  131.          Top             =   -15
  132.          _Version        =   327680
  133.          _ExtentX        =   847
  134.          _ExtentY        =   847
  135.          _StockProps     =   0
  136.          Blocking        =   -1  'True
  137.          Debug           =   1
  138.          Host            =   ""
  139.          LogonName       =   ""
  140.          LogonPassword   =   ""
  141.          Account         =   ""
  142.          Timeout         =   60
  143.          Type            =   0
  144.       End
  145.    End
  146.    Begin VB.PictureBox Picture1 
  147.       Align           =   1  'Align Top
  148.       Height          =   3975
  149.       Left            =   0
  150.       ScaleHeight     =   3915
  151.       ScaleWidth      =   9045
  152.       TabIndex        =   0
  153.       Top             =   0
  154.       Width           =   9105
  155.       Begin VB.ListBox listTrace 
  156.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  157.             Name            =   "Courier New"
  158.             Size            =   8.25
  159.             Charset         =   0
  160.             Weight          =   400
  161.             Underline       =   0   'False
  162.             Italic          =   0   'False
  163.             Strikethrough   =   0   'False
  164.          EndProperty
  165.          Height          =   1110
  166.          Left            =   120
  167.          TabIndex        =   2
  168.          Top             =   360
  169.          Width           =   7935
  170.       End
  171.       Begin VB.ListBox listDir 
  172.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  173.             Name            =   "Courier New"
  174.             Size            =   8.25
  175.             Charset         =   0
  176.             Weight          =   400
  177.             Underline       =   0   'False
  178.             Italic          =   0   'False
  179.             Strikethrough   =   0   'False
  180.          EndProperty
  181.          Height          =   1950
  182.          Left            =   120
  183.          TabIndex        =   1
  184.          Top             =   1800
  185.          Width           =   7935
  186.       End
  187.       Begin VB.Label Label2 
  188.          Caption         =   "Dir List:"
  189.          Height          =   255
  190.          Left            =   120
  191.          TabIndex        =   8
  192.          Top             =   1560
  193.          Width           =   855
  194.       End
  195.       Begin VB.Label Label1 
  196.          Caption         =   "Trace:"
  197.          Height          =   255
  198.          Left            =   120
  199.          TabIndex        =   7
  200.          Top             =   120
  201.          Width           =   975
  202.       End
  203.    End
  204. Attribute VB_Name = "MainForm"
  205. Attribute VB_Creatable = False
  206. Attribute VB_Exposed = False
  207. Option Explicit
  208. Dim frmLoaded As Form
  209. Dim cmdCurrent As CommandButton
  210. Dim fIgnoreListDirClick As Boolean
  211. Public Function ExecuteCommand(action As Integer) As Integer
  212.     On Error Resume Next
  213.     Ftp1.action = action
  214.     If (Err <> 0) Then
  215.         MsgBox Error
  216.     End If
  217.     ExecuteCommand = Err
  218.     On Error GoTo 0
  219. End Function
  220. Sub LoadForm(frmNew As Form, cmdNew As CommandButton)
  221.     If (frmNew Is frmLoaded) Then
  222.         Exit Sub
  223.     End If
  224.     frmNew.Top = 0
  225.     frmNew.Left = 0
  226.     Load frmNew
  227.     frmNew.Show
  228.     If (Not frmLoaded Is Nothing) Then
  229.         frmLoaded.Visible = False
  230.         cmdCurrent.FontBold = False
  231.     End If
  232.     cmdNew.FontBold = True
  233.     Set frmLoaded = frmNew
  234.     Set cmdCurrent = cmdNew
  235. End Sub
  236. Private Sub cmdConnection_Click()
  237.     LoadForm frmConnection, cmdConnection
  238. End Sub
  239. Private Sub cmdDirectory_Click()
  240.     LoadForm frmDirectory, cmdDirectory
  241. End Sub
  242. Private Sub cmdFileTransfers_Click()
  243.     LoadForm frmFileTransfers, cmdFileTransfers
  244. End Sub
  245. Private Sub Ftp1_Progress(ByVal BytesTransfered As Long)
  246.     Label7.Caption = BytesTransfered
  247. End Sub
  248. Private Sub listDir_Click()
  249.     Dim s As String
  250.     Dim i As Integer
  251.        
  252.     If (fIgnoreListDirClick = True Or listDir.ListIndex < 0) Then
  253.         Exit Sub
  254.     End If
  255.     s = listDir.list(listDir.ListIndex)
  256.     i = Len(s)
  257.     Do While (i > 1)
  258.         If (Mid(s, i, 1) = " ") Then
  259.             Debug.Print Mid(s, i + 1)
  260.             SetSelectedServerFile Mid(s, i + 1)
  261.             If (Left(s, 1) = "d" Or Left(s, 1) = "l") Then
  262.                 If (frmLoaded Is frmDirectory) Then
  263.                     frmDirectory.txtDirectory.Text = GetSelectedServerFile
  264.                 ElseIf (frmLoaded Is frmFileTransfers) Then
  265.                     frmFileTransfers.txtGetSrcFilename.Text = ""
  266.                 End If
  267.             Else
  268.                 If (frmLoaded Is frmDirectory) Then
  269.                     frmDirectory.txtDirectory.Text = ""
  270.                 ElseIf (frmLoaded Is frmFileTransfers) Then
  271.                     frmFileTransfers.txtGetSrcFilename.Text = GetSelectedServerFile
  272.                 End If
  273.             End If
  274.             Exit Sub
  275.         End If
  276.         i = i - 1
  277.     Loop
  278. End Sub
  279. Private Sub MDIForm_Load()
  280.     DoEvents
  281.     Ftp1.Type = 0
  282.     LoadForm frmConnection, cmdConnection
  283. End Sub
  284. Private Sub Ftp1_AsyncError(ByVal ErrorNum As Long, ByVal ErrorMsg As String)
  285.     Trace MainForm.listTrace, "Async Error:" & Str(ErrorNum) & " " & ErrorMsg
  286. End Sub
  287. Private Sub Ftp1_Debug(ByVal DebugMsg As String)
  288.     If (Ftp1.Action <> FtpActionGetDirList And Ftp1.Action <> FtpActionGetFilenameList) Then
  289.         Trace MainForm.listTrace, DebugMsg
  290.     End If
  291.     Debug.Print DebugMsg
  292. End Sub
  293. Private Sub Ftp1_DirItem(ByVal Item As String)
  294.     fIgnoreListDirClick = True
  295.     Trace MainForm.listDir, Item
  296.     fIgnoreListDirClick = False
  297. End Sub
  298. Private Sub Ftp1_Done()
  299.     Trace MainForm.listTrace, "done event fired"
  300.     If (Ftp1.Action = 22) Then
  301.         Trace MainForm.listTrace, Ftp1.ReadData
  302.     End If
  303. End Sub
  304. Private Sub MDIForm_Resize()
  305.     listTrace.Width = Me.ScaleWidth - (2 * listTrace.Left)
  306.     listDir.Width = listTrace.Width
  307. End Sub
  308. Private Sub Timer1_Timer()
  309.     lblLastAction.Caption = Ftp1.Action
  310.     lblLastError.Caption = Ftp1.LastError
  311.     lblState.Caption = Ftp1.State
  312. End Sub
  313.